package meijuli.com.join51.business.app;

import android.app.Application;
import android.content.pm.PackageManager;
import android.support.multidex.MultiDexApplication;

import com.jhx.common.app.CommonModule;
import com.jhx.common.thirdparty.bugly.TencentBugly;
import com.jhx.common.thirdparty.db.DBHelper;
import com.jhx.video.module.VideoModule;
import com.umeng.socialize.PlatformConfig;

import cn.jpush.android.api.JPushInterface;
import meijuli.com.join51.business.BuildConfig;

/**
 * 聚惠侠应用实例
 *
 * @author Wizong 2017-05-19 13:09
 */
public class MApplication extends MultiDexApplication {
    private static Application instance;

    static {
        PlatformConfig.setWeixin("wxd4e33aef37d8a4f9", "52073fc51bd76b8d428a9e0d2c39e0b6");
        PlatformConfig.setQQZone("1106404559", "oxagh2t92g5kzpFQ");
        PlatformConfig.setSinaWeibo("2826050078", "ae83ba906ad7ffa703a53323cafb2ee9",
                "http://sns.whalecloud.com");
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        CommonModule.Companion.init(this);
        CommonModule.Companion.debug(BuildConfig.DEBUG);
        VideoModule.Companion.init(this);
        initSdk();
    }

    /**
     * 初始化第三方sdk
     *
     */
    private void initSdk() {
        JPushInterface.setDebugMode(true);
        JPushInterface.init(this);
        DBHelper.Companion.init(this);
        TencentBugly.init();
    }

    public static Application get() {
        return instance;
    }

    public static String getVersion() {
        String versionName = "";
        try {
            //获取软件版本号，对应AndroidManifest.xml下android:versionCode
            versionName = instance.getPackageManager().
                    getPackageInfo(instance.getPackageName(), 0).versionName;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return versionName;
    }

}
